package com.stork.sms.adapter;

import java.util.List;

import com.stork.sms.model.GridMenu;
import com.stork.sms.R;





import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class GridMenuAdapter extends BaseAdapter {
    private Context context;
    List<GridMenu> menuList;
    
	public GridMenuAdapter(Context context, List<GridMenu> menuList) {
		super();
		this.context = context;
		this.menuList = menuList;
	}

	

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return menuList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View row=convertView;
		if(row==null){
			LayoutInflater inflater=((Activity)context).getLayoutInflater();
			row=inflater.inflate(R.layout.menu_grid_row,parent, false);
			TextView menuTitle=(TextView)row.findViewById(R.id.menuTitleText);
			ImageView menuImage=(ImageView)row.findViewById(R.id.menuImageView);
			GridMenu gridMenu=menuList.get(position);
			menuTitle.setText(gridMenu.getMenuName());
			menuImage.setBackgroundResource(gridMenu.getMenuImage());
		}
		return row;
	}

}
